<template>
  <div class="index">
    <el-container>
      <el-header height="68px">
        <m-header></m-header>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <m-aside></m-aside>
        </el-aside>
        <el-main>
          <div class="main">
            <div class="header-top">
              <el-breadcrumb separator-class="el-icon-arrow-right">
                <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
                <el-breadcrumb-item>平台报表</el-breadcrumb-item>
                <el-breadcrumb-item>Excel红包运营数据</el-breadcrumb-item>
              </el-breadcrumb>
              <h2 class="title">Excel红包运营数据</h2>
            </div>
            <div class="row">
              <el-form :inline="true" :model="formInline"  class="demo-form-inline">
                <div class="water">

                  <span class="waterTime">统计时间：</span>
                 
                  <el-date-picker
                    v-model="formInline.time"
                    type="daterange"
                    range-separator="至"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期"
                    @change="changeTime">
                  </el-date-picker>
                </div>
                
                <el-form-item>
                  <el-button type="primary" :loading="onOff" @click="onSubmit">查询</el-button>
                </el-form-item>
              </el-form>

              <el-table
                :data="tableData"
                border
                :cell-style="{'text-align':'center'}"
                :header-cell-style="{
                  'background-color': '#f5f5f5',
                  'color':'#555',
                  'text-align':'center'
                }"
                style="width: 100%">
                <el-table-column
                  prop="tongjiDay"
                  label="统计时间">
                </el-table-column>
                <el-table-column
                label="新手红包">
                  <el-table-column
                    prop="totalPublishHongbao0"
                    label="发放个数">
                  </el-table-column>
                  <el-table-column
                    prop="totalTakeHongbao0"
                    label="被领个数">
                  </el-table-column>
                  <el-table-column
                    prop="totalTakeHongbaoMoney0"
                    label="被领金额">
                  </el-table-column>
                </el-table-column>

                <el-table-column
                label="定时红包">
                  <el-table-column
                    prop="totalPublishHongbao1"
                    label="发放个数">
                  </el-table-column>
                  <el-table-column
                    prop="totalTakeHongbao1"
                    label="被领个数">
                  </el-table-column>
                  <el-table-column
                    prop="totalTakeHongbaoMoney1"
                    label="被领金额">
                  </el-table-column>
                </el-table-column>

                <el-table-column
                  label="转发红包">
                  <el-table-column
                    prop="totalPublishHongbao2"
                    label="发放个数">
                  </el-table-column>
                  <el-table-column
                    prop="totalTakeHongbao2"
                    label="被领个数">
                  </el-table-column>
                  <el-table-column
                    prop="totalTakeHongbaoMoney2"
                    label="被领金额">
                  </el-table-column>
                </el-table-column>
                <el-table-column
                  label="收徒红包">
                  <el-table-column
                    prop="totalPublishHongbao4"
                    label="发放个数">
                  </el-table-column>
                  <el-table-column
                    prop="totalTakeHongbao4"
                    label="被领个数">
                  </el-table-column>
                  <el-table-column
                    prop="totalTakeHongbaoMoney4"
                    label="被领金额">
                  </el-table-column>
                </el-table-column>

                <el-table-column
                  label="收徒瓜分">
                  <el-table-column
                    prop="totalInvitationUserCount"
                    label="收徒用户数">
                  </el-table-column>
                  <el-table-column
                    prop="totalBeInvitatedUserCount"
                    label="裂变收徒个数">
                  </el-table-column>
                
                </el-table-column>           
                
              </el-table>
    
            </div>

          </div>
        </el-main>
      </el-container>

    </el-container>
  </div>
</template>
<script>
import { getCookie,timeChange } from "./until/index";
function init(){
  this.$ajax.get("rptGetHongBaoYunYingShuju.ashx?uid="+getCookie("userid") +"&token=" +getCookie("token")+
        '&startDate='+this.startTime + '&endDate='+this.endTime
      )
      .then(res => {
        
        if (res.data.code === "200") {
          this.onOff = false
          var data = res.data.data;
          this.tableData = data.reportList;
        } else {
          this.onOff = false
          this.$message.error(res.data.msg);
        }
      })
      .catch(error => {
        console.log(error);
      });
}
export default {
  data() {
    return {
      startTime:'',
      endTime:'',
      formInline: {
        time:'',//统计时间
      },
      tableData: [],
      onOff:false

    };
  },
  created() {
    
  },
  methods: {
    onSubmit() {
      if(this.formInline.time){

        this.startTime = timeChange(this.formInline.time[0])
        this.endTime = timeChange(this.formInline.time[1])

      }
      this.onOff = true
      init.call(this)
    },
    changeTime(time){
      
      var time1  = time[0]
      var time2 = time[1]
      if(time2.getTime() - time1.getTime() >= 15 * 24 * 60 * 60 * 1000){
        this.$message.warning('选择时间不能超过15天' );
        this.formInline.time = ''
      }
    }
    
  }
};
</script>
<style scoped>
.index {
  overflow: hidden;
}
.water{margin-right: 10px;display: inline-block}
.waterTime{font-size: 14px;color: #606266;padding: 0 12px 0 0;box-sizing: border-box;}
.el-header {
  background-color: #3a4759;
  color: #fff;
}
.el-aside {
  background-color: #485668;
  color: #333;
  text-align: center;
  line-height: 200px;
  overflow: hidden;
}
.el-main {
  background-color: #f0f2f5;
  color: #333;
  text-align: center;
  height: 100%;
  min-height: 740px
}

.header-top{
  margin: -20px -20px 20px;
  padding: 15px 20px;
  background: #fff;
  
}
.header-top .title{
  margin:15px 0 0;
  font-weight: 600;
  text-align: center;
  font-size: 18px;
}
.row{
  background: #fff;
  padding: 20px 30px;
  text-align: left
}
.block {
  padding: 20px;
}
.message{
  margin-top: 20px;
}
</style>
  